<?php
namespace Biz\model;

use Doraemon\pockets\datebase\BaseDbModel;

class DbStatJson extends BaseDbModel
{

	const _CONFIG_FILE_ = 'db_stat';

	const _CONFIG_SELECT_ = 'db_stat_json';

	const _DATABASE_ = 'stat';

	const _TABLE_NAME = 'hhz_spu_basic_data_month';

	const _SUB_TABLE = true;

	const _SUB_TABLE_FUNCTION = 'dateHash';


	public static function getInfos($dateTime = null)
	{
		if ($dateTime === null) {
			$dateTime = time() - 86400;
		}
		self::enforceSubTableNameBySubKey($dateTime);
		return self::select("*", ['day'=> date("Y-m-d", $dateTime)]);
	}
    public static function getInfoBySpuIds($spuIds = [], $dateTime = null)
    {
        $where = [];
        if ($dateTime === null) {
            $dateTime = time() - 86400;
            $where['day'] = date("Y-m-d", $dateTime);
        }
        if ($spuIds) {
            $where['spu_id'] = $spuIds;
        }
        self::enforceSubTableNameBySubKey($dateTime);
        $rs = self::select("*", $where);
//        var_dump(self::log());
        return $rs;
    }
}